<html>
<head><meta charset="utf-8"><title>using rlib libraries · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/using.20rlib.20libraries.html">using rlib libraries</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="170804828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/using%20rlib%20libraries/near/170804828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Francesco Dainese <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/using.20rlib.20libraries.html#170804828">(Jul 13 2019 at 20:53)</a>:</h4>
<p>Hello everyone.<br>
Today I'm here to ask you how does one link and use an <code>rlib</code>file from within another crate.<br>
I know how to produce an <code>rlib</code> file but after that I don't know how to link it in another crate and how can I actually use the exposed functions.<br>
I tried the <code>links</code> attribute along with an empty build script, since I wanted to use the override anyway, but I couldn't find the key to tell <code>cargo</code> that it should link an <code>rlib</code> and not a normal static lib... So that didn't work.<br>
Suppose I was able to tell <code>cargo</code> to link my <code>rlib</code> file, how am I supposed to use it in my application/library? Should I <code>extern crate my_lib;</code> or <code>extern "C" { fn my_func() }</code>?<br>
Thank you for your help and for your time. If this doesn't belong here let me know.</p>



<a name="170806634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/using%20rlib%20libraries/near/170806634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/using.20rlib.20libraries.html#170806634">(Jul 13 2019 at 21:53)</a>:</h4>
<p>you use rlibs by giving rustc <code>--extern &lt;crate&gt;=&lt;pathtorlib&gt;</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>